<%@include file="menu/util.jsp" %>
<%@page contentType="text/html; charset=iso-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<c:set var="persons" value="${requestScope.persons}" />
<c:set var="maps" value="${requestScope.maps}" />
<c:set var="personsDomain" value="${requestScope.personsDomain}" />
<c:set var="mapDomain" value="${requestScope.mapDomain}" />
<c:set var="domain" value="${requestScope.domain}" />
<c:set var="profiles" value="${requestScope.profiles}" />



<c:if test="${domain != null}" >
    <c:set var="idScoreDomain" value="${domain.idScoreDomain}"/>
    <c:set var="name" value="${domain.name}"/>

</c:if>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <fmt:bundle basename="app">
        <head>
            <title><fmt:message key="login.title.tag" /></title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
            <jsp:include page="menu/header.jsp">
                <jsp:param name="v" value="login" />
            </jsp:include>

            <!-- tabbed panels-->
            <link href="jsp/css/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
            <script src="jsp/js/SpryTabbedPanels.js" type="text/javascript"></script>

            <link href="jsp/css/wizard.css" rel="stylesheet" type="text/css" />
            <link href="jsp/css/screen.css" rel="stylesheet" type="text/css" />

            <script type="text/javascript">
                $(document).ready(function(){
                    $(".buttonCancelTabbedBox").click(function(){
                        parent.$.fn.colorbox.close();
                    });
                });

                $().ready(function(){
                    jQueryFormValidator("#newScoreDomain");
                });
            </script>
        </head>
        <body style="overflow:hidden; background:#fff;">
            <form id="newScoreDomain" action="newScoreDomain.do" method="post">
                <div class="wizard" style="height:380px; width:650px;">
                    <c:choose>
                        <c:when test="${requestScope.edit}">
                            <h1>Editar dominio</h1>
                            <h3>${name}</h3>
                        </c:when>
                        <c:otherwise>
                            <h1>Agregar dominio</h1>
                        </c:otherwise>
                    </c:choose>
                    <div id="dashboardPanels" class="TabbedPanels">
                        <div class="TabbedPanelsContentGroup" style="height:250px; overflow:auto;">

                            <div class="TabbedPanelsContent" >
                                <table style="table-layout:fixed" width="80%" border="0">
                                    <tr>
                                        <td width="40%"><label for="domainName" class="designerWizardLabel">Nombre:</label></td>
                                        <td width="60%"><input type="text" title="<fmt:message key="error.domain.name"/>" class="required designerWizardInput" name="domainName" value="${name}" /></td>
                                    </tr>
                                    <tr>
                                        <td width="40%"><label for="domainName" class="designerWizardLabel">Mapa:</label></td>
                                        <td width="60%">
                                            <select class="designerWizardInput" name="map">

                                                <c:if test="${mapDomain != null}">
                                                    <option value="${mapDomain.idScoreCard}">${mapDomain.name}</option>
                                                </c:if>

                                                <c:forEach items="${maps}" var="map">
                                                    <option value="${map.idScoreCard}">${map.name}</option>
                                                </c:forEach>
                                            </select>
                                        </td>
                                    </tr>
                                </table>
                                <h1 style="border-bottom:2px solid #003a63; padding:5px 0; font-size:17px;">Usuarios</h1>
                                <table style="table-layout:fixed" width="100%" border="0">

                                    <c:if test="${personsDomain != null}">
                                        <c:forEach items="${personsDomain}" var="personDomain" varStatus="status">
                                            <c:set var="personType" value="${personTypes[personDomain]}" />
                                            <c:if test="${status.count % 3 == 1}">
                                                <tr>
                                                </c:if>
                                                <td width="8%" align="left">
                                                    <input type="checkbox" name="person" id="person-${personDomain.idPerson}" value="${personDomain.idPerson}" checked="true" />
                                                </td>
                                                <td width="25%" align="center">
                                                    <label for="person-${personDomain.idPerson}">${personDomain.name}</label>
                                                    <select class="designerWizardInput" name="typePerson-${personDomain.idPerson}" id="typePerson-${personDomain.idPerson}">
                                                        <option value="${personType.profile}">
                                                            <c:choose>
                                                                <c:when test="${personType.profile == 'CORE_TEAM'}"><fmt:message key="forms.core_team" /></c:when>
                                                                <c:when test="${personType.profile == 'FINAL_USER'}"><fmt:message key="forms.final_user" /></c:when>
                                                            </c:choose>
                                                        </option>
                                                        <c:forEach items="${profiles}" var="profilePerson">
                                                            <option value="${profilePerson}">
                                                                <c:choose>
                                                                    <c:when test="${profilePerson == 'CORE_TEAM'}"><fmt:message key="forms.core_team" /></c:when>
                                                                    <c:when test="${profilePerson == 'FINAL_USER'}"><fmt:message key="forms.final_user" /></c:when>
                                                                </c:choose>
                                                            </option>
                                                        </c:forEach>


                                                    </select>
                                                </td>
                                                <c:if test="${status.count % 3 == 0}">
                                                </tr>
                                            </c:if>
                                        </c:forEach>

                                    </c:if>

                                    <c:forEach items="${persons}" var="person" varStatus="status">
                                        <c:if test="${status.count % 3 == 1}">
                                            <tr>
                                            </c:if>
                                            <td width="8%" align="left">
                                                <input type="checkbox" name="person" id="person-${person.idPerson}" value="${person.idPerson}" />
                                            </td>
                                            <td width="25%" align="center">
                                                <label for="person-${person.idPerson}">${person.name}</label>
                                                <select class="designerWizardInput" name="typePerson-${person.idPerson}" id="typePerson-${person.idPerson}">

                                                    <c:forEach items="${profiles}" var="profilePerson">
                                                        <option value="${profilePerson}">
                                                            <c:choose>
                                                                <c:when test="${profilePerson == 'CORE_TEAM'}"><fmt:message key="forms.core_team" /></c:when>
                                                                <c:when test="${profilePerson == 'FINAL_USER'}"><fmt:message key="forms.final_user" /></c:when>
                                                            </c:choose>
                                                        </option>
                                                    </c:forEach>


                                                </select>
                                            </td>
                                            <c:if test="${status.count % 3 == 0}">
                                            </tr>
                                        </c:if>
                                    </c:forEach>
                                </table>
                            </div>

                        </div>
                    </div>

                    <div class="errorDiv">

                    </div>
                    <div class="botonesWizard">
                        <c:choose>
                            <c:when test="${requestScope.edit}">
                                <input name="send" type="submit" id="send" class="buttonTabbedBox" value="Editar dominio" />
                            </c:when>
                            <c:otherwise>
                                <input name="send" type="submit" id="send" class="buttonTabbedBox" value="Agregar dominio" />
                            </c:otherwise>
                        </c:choose>
                        <input name="Reset" type="reset" class="buttonCancelTabbedBox" value="Cancelar" />
                    </div>
                    <div class="clear"></div>
                </div>

                <input type="hidden" id="idScoreDomain" name="idScoreDomain" value="${idScoreDomain}" />
            </form>
        </body>
    </fmt:bundle>
</html>

